#include "LPC11xx.h"
#define LED1_ON LPC_GPIO2->DATA&=~(1<<0)
#define LED1_OFF LPC_GPIO2->DATA|=(1<<0)

 
 void LedInit()
 {
  LPC_SYSCON ->SYSAHBCLKCTRL |=(1<<16);
  LPC_IOCON ->PIO2_0 &=~0x07;
  LPC_IOCON ->PIO2_0 |=0x00;
  LPC_SYSCON ->SYSAHBCLKCTRL &=~(1<<16);
  LPC_SYSCON ->SYSAHBCLKCTRL |=(1<<6);	 
	LPC_GPIO2->DIR|=(1<<0);
	LPC_GPIO2->DATA|=(1<<0);
 }
 
 void T32B1_Init(void)
 {
  LPC_SYSCON ->SYSAHBCLKCTRL|=(1<<10);
	LPC_TMR32B1->IR = 0x01;
  LPC_TMR32B1->MCR =0x04;	 
 
 }
 void T32B1_DelayMs(uint16_t ms)
 {
  LPC_TMR32B1->TCR=0x02;
  LPC_TMR32B1->PR=0;
	LPC_TMR32B1->MR0=ms*(SystemCoreClock/1000);
	LPC_TMR32B1->TCR=0x01;
	 while(LPC_TMR32B1->TCR&0x01);
 }
 int main()
 {
  LedInit ();
	 T32B1_Init();
	 while(1)
	 {
		 T32B1_DelayMs(1000);
		 LED1_ON;
		 T32B1_DelayMs(1000);
		 LED1_OFF;
	 }
 }